package ipc;

import java.util.List;
import java.util.Random;

public class RandomAgent<S extends State, A> extends Agent<S, A>{
	
	private Simulator<S,A> simulator;
	private Random rand;

	public RandomAgent(Simulator<S,A> simulatedworld, long seed) {
		this.simulator = simulatedworld;
		this.rand = new Random(seed);
	}

	@Override
	public A selectAction(S state, long timeout, int i) {
		simulator.setState(state);
		List<A> legals = simulator.getLegalActions();
		return legals.get((int)(rand.nextDouble()*legals.size()));
	}
	

}
